package vista;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import controlador.Sistema;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AltaTarjeta extends javax.swing.JFrame {
	private JLabel lblNumero;
	private JLabel lblLimite;
	private JButton btnCancelar;
	private JTextField txtDNI;
	private JLabel lblDNI;
	private JButton btnAceptar;
	private JTextField txtLimite;
	private JTextField txtNumero;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	public AltaTarjeta() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Alta de Tarjeta");
			getContentPane().setLayout(null);
			{
				lblNumero = new JLabel();
				getContentPane().add(lblNumero);
				lblNumero.setText("Numero: ");
				lblNumero.setBounds(60, 95, 78, 14);
			}
			{
				lblLimite = new JLabel();
				getContentPane().add(lblLimite);
				lblLimite.setText("Limite: ");
				lblLimite.setBounds(60, 149, 78, 14);
			}
			{
				txtNumero = new JTextField();
				getContentPane().add(txtNumero);
				txtNumero.setBounds(161, 88, 129, 21);
			}
			{
				txtLimite = new JTextField();
				getContentPane().add(txtLimite);
				txtLimite.setBounds(157, 142, 129, 21);
			}
			{
				btnAceptar = new JButton();
				getContentPane().add(btnAceptar);
				btnAceptar.setText("Aceptar");
				btnAceptar.setBounds(95, 204, 89, 21);
				btnAceptar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						Sistema.getInstancia().crearTarjeta(txtDNI.getText(), Integer.parseInt(txtNumero.getText()), Integer.parseInt(txtLimite.getText()));
						limpiarCampos();
					}
				});
			}
			{
				btnCancelar = new JButton();
				getContentPane().add(btnCancelar);
				btnCancelar.setText("Cancelar");
				btnCancelar.setBounds(207, 204, 95, 21);
				btnCancelar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
					}
				});
			}
			{
				lblDNI = new JLabel();
				getContentPane().add(lblDNI);
				lblDNI.setText("DNI: ");
				lblDNI.setBounds(65, 48, 78, 14);
			}
			{
				txtDNI = new JTextField();
				getContentPane().add(txtDNI);
				txtDNI.setBounds(161, 41, 129, 21);
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	private void limpiarCampos() {
		txtLimite.setText("");
		txtNumero.setText("");
	}
}
